<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // 就是找一串字符串中, 连续相同且个数大于等于3的字符的 开始和结束 索引
    function fn(s) {
      let arr = s[0], j = 0, res = []
      for (let i = 1; i <= s.length; i++) {
        if (arr === s[i]) continue
        if (i - j >= 3) res.push([j, i - 1])
        arr = s[i]
        j = i
      }
      return res
    }
    console.log(fn("abbxxxxzzy"))
  </script>
</body>

</html>